from .common_imports import BaseModel, User, models
from ..models.class_subject_assignment import ClassSubjectAssignment
from datetime import date, timedelta

class Homework(BaseModel):
    """作业"""
    class_subject = models.ForeignKey(ClassSubjectAssignment, on_delete=models.CASCADE, related_name='homeworks', verbose_name="班级学科")

    content = models.CharField(max_length=200, verbose_name="作业内容")
    assigned_date = models.DateField(default=date.today, verbose_name="布置日期")
    due_date = models.DateField(default= date.today() + timedelta(days=1) , verbose_name="截止日期")

    def __str__(self):
        return f"{self.class_subject} - {self.content}"

    class Meta:
        verbose_name = "作业"
        verbose_name_plural = "作业"